package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.GroupCategoryStatus;

/**
 *  TABLE NHOM LOAI
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 27-02-2014 - 17:57:53
 */

@Entity
@Table(name = "GROUP_CATEGORY")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "GROUP_CATEGORY_SEQ", allocationSize = 1)
public class GroupCategory implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
//	@Index(name="GROUP_CATEGORY_ID_PK")
	private Integer id;
	
	/**
	 * MA TO BAO
	 */
	@Basic
	@Column(name = "CODE", length = 20)
	private String code;
	
	/**
	 * TO BAO
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "GROUP_CATEGORY_MEDIA_FK")
	private Media media;
	
	/**
	 * TEN THE LOAI
	 */
	@Basic
	@Column(name = "NAME", length = 100)
	private String name;
	
	/**
	 * TEN THE LOAI
	 */
	@Basic
	@Column(name = "NAME_TEXT", length = 100)
	private String nameText;
	
	/**
	 * ID CHA
	 */
	@Basic
	@Column(name = "PARENT_ID")
	@Index(name="GROUP_CATEGORY_PARENT_IDX")
	private Integer parentId;
	
	/**
	 * TRANG THAI
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.GroupCategoryStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="GROUP_CATEGORY_STATUSX")
	private GroupCategoryStatus status;

	/**
	 * MO TA
	 */
	@Basic
	@Column(name = "DESCRIPTION", length = 2000)
	private String description;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	public GroupCategoryStatus getStatus() {
		return status;
	}

	public void setStatus(GroupCategoryStatus status) {
		this.status = status;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	public String getNameText() {
		return nameText;
	}

	public void setNameText(String nameText) {
		this.nameText = nameText;
	}

	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	
}